package cn.tedu.rabbitmq.m2;

import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {


    @Autowired
    private Producer p;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public Queue taskQueue(){
        //默认是持久队列 true ，false，false
        return new Queue("helloworld",true);
    }

    //spring扫描创建完所有的实例 完成所有的依赖注入后，
    //自动执行@PostConstruct 注解方法
    @PostConstruct
    public void test(){
        //lambda 表达式 == Runable 匿名内部类
        new Thread(()->p.send()).start();
    }

}
